import { PathFinderManager } from "../PathFinderManager";
import { ACostDecorate } from "./ACostDecorate";

/**
 * 自己房间的布局缓存寻路,一般用来寻找放路
 * 目前只用来寻路了
 */
export class ACreepStructurePlanBlock extends ACostDecorate
{
    decorate(manager:PathFinderManager,roomName: string, costs: CostMatrix,opt:IPathFinderOpt): CostMatrix 
    {
        const room = Game.rooms[roomName]
        if(room && room.getType()==1)
        {
            const structcache = room.getWorld().PollBlueplan(room.name);
            if(structcache)
            {
                const mycostcache = structcache.getMatrix().clone();
                costs=(mycostcache);
                // 同时中心位置也要屏蔽
                if(room.memory.center)
                {
                    costs.set(room.memory.center[0],room.memory.center[1],0xff)
                }
                
                return mycostcache
            }
            else
            {
                //
                room.log(`error`,`找不到建筑缓存`);
                // throw new Error(`${room.name} 本房间 找不到 建筑缓存`);
            }
        }
        return costs
    }

}